let LinearArray=[];
function changeIntoLinearArray(array1){
  for(let item of array1){
    if(Array.isArray(item)){
      changeIntoLinearArray(item);
    }
    else{
      LinearArray.push(item);
    }
  }
  return LinearArray;
}

function include(collection,ch){
  for(let item of collection){
    if(item===ch){
      return true;
    }
  } 
}

function collectSameElements(collectionA, collectionB) {
  let result=[];
  collectionB=changeIntoLinearArray(collectionB);
  for(let item of collectionA){
    if(include(collectionB,item)){
      result.push(item);
    }
  }
  console.log(result);
  return result;
}
module.exports =collectSameElements;
collectSameElements(['a', 'e', 'h', 't', 'f', 'c', 'g', 'b', 'd'],[['a', 'd', 'e', 'f']]);